// https://www.acwing.com/problem/content/802/

#include <iostream>
#include <vector>
using namespace std;

int main() {
    int m, n, target;
    cin>>m>>n>>target;
    vector<int> nums1(m);
    vector<int> nums2(n);

    for (int i=0; i<m; i++) {
        cin>>nums1[i];
    }

    for (int i=0; i<n; i++) {
        cin>>nums2[i];
    }

    int t1 = 0;
    int t2 = n - 1;
    while (t1 < m && t2 >= 0) {
        int  sum = nums1[t1] + nums2[t2];
        if (sum < target) {
            t1++;
        } else if (sum > target) {
            t2--;
        } else {
            cout<<t1<<" "<<t2<<endl;
            break;
        }
    }
    return 0;
}